home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: newshub.nosc.mil!news!news
- From: sampson@cod.nosc.mil (Charles H. Sampson)
- Subject: Specifying Data Layout
- Message-ID: <1996Mar14.173643.8651@nosc.mil>
- Sender: news@nosc.mil
- Organization: Computer Sciences Corporation
- Date: Thu, 14 Mar 1996 17:36:43 GMT
-
- I've just finished reading the reference manual part of Stroustrup's
- "The C++ Programming Language" (2nd ed) and have a number of questions.
- This one is particularly important to a project I'm working on. A quick
- search of the FAQ didn't turn up anything, nor does it seem to appear in
- the 1400+ articles currently in the comp.lang.c++ newsgroup on my news
- server.
-
- Is there some way of precisely specifying the memory layout of a
- struct? In other words, can you say, "This struct is to occupy 3 words of
- memory, element foo is to occupy bits 5-12 of word 1, element fern is to
- occupy ..."? If it can be done with a struct, can it also be done with a
- class (specifying locations for the data members only)? In this case, can
- you also control the gizmo that is used to distinguish the various values
- of a class hierarchy, both where it is to be allocated and the values to be
- used to identify specific members of the hierarchy?
-
- For those who don't understand why anyone would want to do such stuff,
- the issue is trying to make a class hierarchy out of data that were defined
- and mapped to bits long before OO concepts arose.
-
- For reference, in Ada the technique for specifying the exact bits of a
- struct (record) is called a representation specification and the gizmo is
- called the class's tag. (I'm not trying to wave any red flags here; just
- attempting to use a precise term where it exists.)
-
- Charlie
-